/*

Stickman Adventure - a game created by Daco & his cousin

Copyright (C) 2011-2012  DacoTaco & Wouterke

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation version 2.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.


*/
#ifndef _MAP_FILE_H
#define _MAP_FILE_H

#include <string>
#include <vector>

#ifndef uint32_t
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
//typedef __int8 int8_t;
//typedef unsigned __int8 uint8_t;
#endif

struct _map_file_header
{
	unsigned int sig;
	unsigned int map_x;
	unsigned int map_y;
	unsigned int entries;
};
struct _map_file_entry
{
	unsigned int x;
	unsigned int y;
	unsigned int w;
	unsigned int h;
	unsigned char name_size;
	std::string texture_name;
	unsigned char desc_size;
	std::string entry_desc;
	unsigned char command;
	unsigned char subcommand;
	unsigned char type;
	unsigned int ending;
};

#define MAP_SIZE_ENTRIES sizeof(int)*4

extern std::vector< _map_file_entry > map_file;
extern int map_x;
extern int map_y;

char VerifyMap(char *filename);
char ReadMap(std::string filename);
char WriteMap(std::string filename);
size_t write_file( FILE* file, void* nbr ,int size );
size_t read_file( FILE* file, void* nbr ,int size );
//endian shit
int is_big_endian(void);
inline void endian_swap(unsigned short& x);
inline void endian_swap(unsigned int& x);
inline void endian_swap(unsigned __int64& x);
#endif
